package com.vogtec.fota.mqtt;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttAsyncClient;
import org.eclipse.paho.client.mqttv3.MqttException;

import java.util.Arrays;

/**
 * Created by TieYan on 2017/5/22.
 */
@Slf4j
public class BikeEmqttClient {
	private MqttAsyncClient mqttClient;

	public MqttAsyncClient getMqttClient() {
		return mqttClient;
	}

	public void setMqttClient(MqttAsyncClient mqttClient) {
		this.mqttClient = mqttClient;
	}

	public void publish(byte[] payload, String topic) throws MqttException {
		log.info("\n> > > > > > > publish to " + topic + "> > > > > > > > >\n"
				+ Arrays.toString(payload)
				+ "\n> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >\n");
		mqttClient.publish(topic, payload, 1, false);//TODO config
	}
}
